<template>
  <div>
    <el-form :model="form" :rules="rules" ref="formRef">
      <el-form-item label="可提现最小金额：" prop="price" :label-width="formLabelWidth">
        <el-input-number
          type="number"
          :min="0"
          :max="1000000000"
          controls-position="right"
          v-model="form.price"
          :precision="0"
          :step="1"
          style="margin-left:15px"
        ></el-input-number>
        <span>元</span>
      </el-form-item>
    </el-form>
    <div style="text-align:center; margin-top: 50px;">
      <el-button type="primary" @click="submitForm('formRef')" v-if="isPermissionsBtn('withdrawalSet_add')">保存</el-button>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
  name: "",
  data() {
    return {
       formLabelWidth:"150px", 
      form: {
        price: ""
      },
      rules: {
        price: [{ required: true, message: "请输入金额", trigger: "blur" }]
      }
    };
  },
  components: {},
  computed: {
    ...mapGetters(["isPermissionsBtn"])
  },
  beforeMount() {},
  mounted() {
    this.initData();
  },
  methods: {
    initData(){
      this.$service.minimumMoney().then(res => {
        if (res.code == "00000") {
          this.form.price =res.data/100
        }
      });
    },
    submitForm(formName){
      this.$refs[formName].validate(valid => {
        let message = this.form;
        if (valid) {
          this.$service.updateMoney(message.price).then(res => {
            if (res.code == "00000") {
              this.$message({
                message: "提交成功",
                type: "success"
              });
              this.initData();
            } else {
              this.$message({
                message: res.message,
                type: "warning"
              });
            }
          });
        }
      });
    }
  },
  watch: {}
};
</script>
<style scoped>
</style>
